package com.fjec.market.feign;

import com.fjec.market.feign.config.FeignConfig;
import com.fjec.market.feign.fallback.UserClientFallback;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@FeignClient(name = "user-serv", fallback = UserClientFallback.class, configuration = FeignConfig.class)
public interface UserClient {

    @RequestMapping(method = RequestMethod.POST, value = "/api/n/role/saveUserRole")
    String saveUserRole(@RequestParam("userId") Long userId, @RequestParam("roleCode") String roleCode);


    /**
     * 修改注册用户电话号码
     *
     * @param userId
     * @param phone
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/user/phone/update")
    int updateUserPhone(@RequestParam("userId") Long userId,
                        @RequestParam("phone") String phone);

    /**
     * 获取用户的未读消息数量
     *
     * @param userId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/im/unread/num")
    Map<String, Object> getUnReadNum(@RequestParam("userId") Long userId);

    /**
     * 电话号码是否存在
     *
     * @param phone
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/phone/exists")
    boolean existsPhone(@RequestParam("phone") String phone);

    /**
     * 为创建商户更新用户信息
     *
     * @param dataMap
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/update/for/create/shop")
    int updateUserInfoForCreateShop(@RequestBody Map<String, Object> dataMap);

    @RequestMapping(method = RequestMethod.GET, value = "/api/user/getOpenIdByUserId")
    Map<String, Object> getOpenIdByUserId(@RequestParam("userId") Long userId);
}
